using MicroMsg.Common.Utils;
using System;
using System.IO.IsolatedStorage;
namespace MicroMsg.Storage
{
	public class ShakeStorage
	{
		private const string imageFileName = "/shake_bg.jpe";
		public static string getImgPath()
		{
			return StorageIO.getShakePath() + "/shake_bg.jpe";
		}
		public static void saveImg(byte[] imageBuf)
		{
			if (imageBuf != null && imageBuf.Length > 0)
			{
				try
				{
					using (IsolatedStorageFile userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication())
					{
						string imgPath = ShakeStorage.getImgPath();
						if (userStoreForApplication.FileExists(imgPath))
						{
							userStoreForApplication.DeleteFile(imgPath);
						}
						IsolatedStorageFileStream isolatedStorageFileStream = userStoreForApplication.CreateFile(imgPath);
						if (isolatedStorageFileStream != null)
						{
							isolatedStorageFileStream.Write(imageBuf, 0, imageBuf.Length);
							isolatedStorageFileStream.Dispose();
						}
					}
				}
				catch (Exception ex)
				{
					Log.smethod_1("ShakeStorage", "save image error " + ex);
				}
				return;
			}
		}
	}
}
